﻿requirejs.config({
    baseUrl: ".",
    paths: {
    	zepto:"javascripts/zepto.min",
    	dingtalk:"javascripts/dingtalk",
        vue: "components/vue/vue.min",
        axios: "components/axios/axios.min",
        MINT: "components/mint-ui/index",
        common: "resources/js/common"
    },
    shim: {
        "MINT": {
            deps: ["vue"],
            exports: "MINT"
        }
    }
});

require(["zepto","dingtalk","vue", "axios", "common", "MINT"], function (zepto,dingtalk,Vue, axios, common, MINT) {

    Vue.component(MINT.Navbar.name, MINT.Navbar);
    Vue.component(MINT.TabItem.name, MINT.TabItem);
    Vue.component(MINT.TabContainer.name, MINT.TabContainer);
    Vue.component(MINT.TabContainerItem.name, MINT.TabContainerItem);
    Vue.component(MINT.Popup.name, MINT.Popup);

    var vm = new Vue({
        el: "#view",
        data: {
            selected: "assignment",
            assignment: [],
            resolved: [],
            detail: {},
            popup_visible: false
        },
        mounted: function () {
            var cus_user_id = common.getParam("cus_user_id");
            axios.get("/incident/history?cus_user_id=" + cus_user_id)
                .then(function (response) {
                    for (var i = 0; i < response.data.length; i++) {
                        if (response.data[i].status == "待分派") {
                            vm.assignment.push(response.data[i]);
                        }
                        if (response.data[i].status == "已关闭") {
                            vm.resolved.push(response.data[i]);
                        }
                    }
                });
        },
        methods: {
            showDetail: function (detail) {
                this.detail = detail;
                this.popup_visible = true;
            },
            hideDetail: function () {
                this.popup_visible = false;
            }
        }
    });

});